<admintpl file="header" />
</head>
<body><div class="wrap js-check-wrap">
		<ul class="nav nav-tabs">
			<li class="active" href="#A" data-toggle="tab"><a href="{:U('Menu/index')}">菜单列表</a></li>
			<li><a href="{:U('Menu/add')}">添加菜单</a></li>
			<li><a href="#B" data-toggle="tab">更新微信菜单</a></li>
		</ul>
        <div class="tabbable">
            <div class="tab-content">
        <div class="tab-pane active" id="A">
		<form method="post" class="js-ajax-form" action="{:U('Menu/listorders')}">
			<div class="table-actions">
				<button type="submit" class="btn btn-primary btn-small js-ajax-submit">{:L('SORT')}</button>
			</div>
			<table class="table table-hover table-bordered table-list">
				<thead>
					<tr>
						<th width="50">排序</th>
						<th width="50">ID</th>
						<th>菜单名称</th>
						<th>事件类型</th>
						<th>事件属性</th>
						<th>状态</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody>
					{$taxonomys}
				</tbody>
				<tfoot>
					<tr>
                        <th width="50">排序</th>
                        <th width="50">ID</th>
                        <th>菜单名称</th>
                        <th>事件类型</th>
                        <th>事件属性</th>
                        <th>状态</th>
                        <th>操作</th>
					</tr>
				</tfoot>
			</table>
			<div class="table-actions">
				<button type="submit" class="btn btn-primary btn-small js-ajax-submit">{:L('SORT')}</button>
			</div>
		</form>
            </div>
        <div class="tab-pane" id="B">
            <div class="wrap">
            <button class="btn btn-primary weixinBtn" type="button" data-url="{:U('Menu/createMenu')}">创建微信菜单</button>
            <button class="btn btn-primary weixinBtn" type="button" data-url="{:U('Menu/queryMenu')}">查询微信菜单</button>
            <button class="btn btn-primary weixinBtn" type="button" data-url="{:U('Menu/deleteMenu')}">删除微信菜单</button>
            </div>
            <div class="wrap"><span id="errmsg"></span></div>
	</div>
</div></div></div>
	<script src="__PUBLIC__/js/common.js"></script>
<script>
    $(document).ready(function () {

        $('.weixinBtn').click(function () {
            var _this =$(this);
            var old_text =_this.text();
            var btnurl =_this.data('url');
            _this.text("更新中...");
           	$.ajax({
           	  	url: btnurl,
           	  	type: 'POST',
           	  	dataType: 'json',
           	  	data: {param1: 'value1'},
           	  })
           	  .done(function(data) {
           	  	if (data.errcode=='0'){
//                    _this.text('操作成功...');
                    $('#errmsg').text("操作成功...");
                }else{
                    $('#errmsg').text("errcode:"+data.errcode +'\n\r errmsg:'+data.errmsg);
//                    _this.text('操作失败...');
                }
           	  })
           	  .fail(function() {
           	  	_this.text('操作失败...');
           	  })
           	  .always(function() {
           	  	_this.text(old_text);
           	  });

        })

    })
    
    
    
</script>
</body>
</html>